<% layout('/layouts/default.html', {title: '任务部署信息表(主)管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-tools pull-left" style="position: relative">
				<ul class="nav nav-tabs bangPing-tabs">
					<li class="active"><a href="${ctx}/taskdeploy/dcSupTaskInfo/list">${text('待提交')}</a></li>
					<li ><a href="${ctx}/taskdeploy/dcSupTaskInfo/listed">${text('已提交')}</a></li>
				</ul>
			</div>
			<#form:form id="searchForm" model="${dcSupTaskInfo}" action="${ctx}/taskdeploy/dcSupTaskInfo/queryListData?taskStatus=1&normalFlag=1" method="post" class="form-inline"
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
			<div style="float: right">
				<div class="form-group">
					<label class="control-label">${text('任务年度')}：</label>
					<div class="control-inline width-120">
						<#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-120" defaultValue="${currentYear}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务信息')}：</label>
					<div class="control-inline width-160">
						<#form:input path="taskTitle" maxlength="200" class="form-control width-160" placeholder="请输入任务标题或内容"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('任务类型')}：</label>
					<div class="control-inline width-160">
						<#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
					</div>
				</div>
				<div class="form-group">
					<!--					<label class="control-label">${text('数据过滤')}：</label>-->
					<div class="control-inline width-90">
						<% if(hasRole('other_office')){ %>
						<% var items = [{label:'我的',value:'0'}]; %>
						<#form:select path="dataLimit" items="${items}" itemLabel="label" itemValue="value" defaultValue="0" class="form-control required" />
						<% } else{ %>
						<% var items = [{label:'我的',value:'0'},{label:'本单位',value:'1'}]; %>
						<#form:select path="dataLimit" items="${items}" itemLabel="label" itemValue="value" defaultValue="0" class="form-control required" />
						<% } %>

					</div>
				</div>
				<div class="form-group" >
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
					<a href="#" class="btn btn-default" id="btnImport"><i class="glyphicon glyphicon-import"></i> ${text('导入')}</a>
				</div>
			</div>
		</#form:form>
	</div>
	<div class="box-body">
			<a href="#"  onclick="addTask()" class="btn btn-primary btn-sm mr10 mb10" style="background-color:#00B7EE;border-color: #00b7ee" title="${text("新增督办事项")}"><i class="fa fa-plus"></i> 新增督办事项</a>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>
</div>
</div>
<% } %>
<script>
	//重置
	function cz(){
		searchForm.reset();
		$('#dataGrid').dataGrid('reloadGrid');
	}

	//打开新的标签
	function addTask() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/form?normalFlag="+1, true);
	}
	function addTaskMulti() {
		js.addTabPage(null, "新增督办事项","${ctx}/taskdeploy/dcSupTaskInfo/multiForm?normalFlag="+2, true);
	}

	// 初始化DataGrid对象
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		sortableColumn: false, // 列表不允许排序
		columnModel: [
			{header:'${text("主键")}', name:'id', index:'a.id', width:150, align:"left", hidden:true},
			{header:'${text("督办字号")}', name:'messageNumber', index:'a.message_number', width:100, align:"left"},
			{header:'${text("任务标题")}', name:'taskTitle', index:'a.task_title', width:150, align:"left"
				, formatter: function(val, obj, row, act){
					if(((row.auditorCode==''||row.auditorCode==null)&&row.taskStatus=='2'&&!row.taskSupOrg)||row.taskStatus=='3'||row.taskStatus=='5'||row.taskStatus=='7'||row.taskStatus=='8'||row.taskStatus=='9'){
						return '<a href="${ctx}/action/dcSupTaskAction/listOrg?taskId='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无标题')+'</a>';}else{
						return val;
					}
				}
			},
			{header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
			{header:'${text("任务内容")}', name:'taskContent', index:'a.task_content', width:150, align:"left", formatter: function(val, obj, row, act){
					return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
				}},			{header:'${text("牵头领导")}', name:'taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},
		/*	{header:'${text("调度人")}', name:'contactName', index:'a.contact_name', width:100, align:"left"},*/
			{header:'${text("牵头责任单位")}', name:'taskLeaderOrgName', index:'a.task_leader_org_name', width:150, align:"left"},
			{header:'${text("任务状态")}', name:'taskStatus', index:'a.task_status', width:150, align:"center"
				,formatter: function(val, obj, row, act){
					return js.getDictLabel(${@DictUtils.getDictListJson('dc_task_status')}, val, '${text("未知")}', true);
				}},
			{header:'${text("操作")}', name:'actions', width:150, align:"center",formatter: function(val, obj, row, act){
					var actions = [];
					if(row.taskStatus=='1'||row.taskStatus=='4'||row.taskStatus=='6'){
						actions.push('<a href="#" class="btn btn-primary btn-xs " onclick=editTask("'+row.id+'") title="${text("编辑督办事项")}">编辑</a>&nbsp;&emsp;');}
					actions.push('<a href="${ctx}/taskdeploy/dcSupTaskInfo/deleteById?id='+row.id+'" class="btn btn-danger btn-xs btnList" title="${text("删除任务")}" data-confirm="${text("确认要彻底删除该任务吗？")}">删除</a>&nbsp;');
					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});

	// 编辑任务
	function editTask(id) {
		js.addTabPage(null, "编辑督办任务","${ctx}/taskdeploy/dcSupTaskInfo/form?id="+id , true);
	}

	// 导入
	$('#btnImport').click(function(){
		js.layer.open({
			type: 1,
			area: ['400px'],
			title: '${text("导入督办数据")}',
			resize: false,
			scrollbar: true,
			shadeClose: false,
			content: js.template('importTpl'),
			success: function(layero, index){
				layero.find('input[type="checkbox"]').iCheck();
			},
			btn: ['<i class="fa fa-check"></i> ${text("导入")}',
				'<i class="fa fa-remove"></i> ${text("关闭")}'],
			btn1: function(index, layero){
				var form = {
					inputForm: layero.find('#inputForm'),
					file: layero.find('#file').val()
				};
				if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
					js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
					return false;
				}
				js.ajaxSubmitForm(form.inputForm, function(data){
					js.showMessage(data.message);
					if(data.result == Global.TRUE){
						js.layer.closeAll();
					}
					page();
				}, "json");
				return true;
			}
		});
	});
</script>
<script id="importTpl" type="text/template">//<!--
<form id="inputForm" action="${ctx}/taskdeploy/dcSupTaskInfo/importData" method="post" enctype="multipart/form-data"
	class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
	<div class="row">
		<div class="col-xs-12 col-xs-offset-1">
			<input type="file" id="file" name="file" class="form-file"/>
			<div class="mt10 pt5">

				<a href="${ctx}/taskdeploy/dcSupTaskInfo/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
			</div>
			<font color="red" class="pull-left mt10">
				${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
			</font>
		</div>
	</div>
</form>
//--></script>